
export default {

  grid: {//设置图表四周留白间距
    top: '15%',
    right: '0',
    bottom: '9%',
    left: '10%'
  },
  tooltip: {
    trigger: 'axis',
    position: function (point, params, dom, rect, size) {
      // 鼠标坐标和提示框位置的参考坐标系是：以外层div的左上角那一点为原点，x轴向右，y轴向下
      // 提示框位置
      let x = 0; // x坐标位置
      let y = 0; // y坐标位置
      // 当前鼠标位置
      let pointX = point[0];
      let pointY = point[1];
      // 提示框大小
      let boxWidth = size.contentSize[0];
      let boxHeight = size.contentSize[1];
      // boxWidth > pointX 说明鼠标左边放不下提示框
      if (boxWidth > pointX) {
        x = pointX + 20;
      } else { // 左边放的下
        x = pointX - boxWidth - 20;
      }
      // boxHeight > pointY 说明鼠标上边放不下提示框
      if (boxHeight > pointY) {
        y = 5;
      } else { // 上边放得下
        y = pointY - boxHeight;
      }
      return [x, y];
    },
  },
  legend: {
    textStyle: {
      color: '#fff'
    },
  },
  xAxis: {
    type: 'category',
    boundaryGap: false,
    data: [],
    axisLabel: {
      fontSize: 10,
      formatter: (value) =>  //X轴的内容
      {

        let ret = ""; //拼接加\n返回的类目项
        let max = 10;  //每行显示的文字字数
        let val = value.length;  //X轴内容的文字字数
        let rowN = Math.ceil(val / max);  //需要换的行数
        if (rowN > 1)  //判断 如果字数大于2就换行
        {
          for (let i = 0; i < rowN; i++) {
            let temp = "";  //每次截取的字符串
            let start = i * max;  //开始截取的位置
            let end = start + max;  //结束截取的位置
            temp = value.substring(start, end) + "\n";
            ret += temp;  //最终的字符串
          }
          return ret;
        }
        else { return value }
      },

    },

  },
  yAxis: {
    axisLabel: {
      fontSize: 10
    },
    splitLine: {
      lineStyle: {
        color: "rgba(255,255,255,0.05)"
      }
    },
    type: 'value'
  },
  series: [{
    data: [],
    type: 'line',
    symbol: 'circle',
    color: '#2f63e7', //改变折线点的颜色
    lineStyle: {
      color: {
        type: 'linear',
        x: 0,
        y: 0,
        x2: 0,
        y2: 1,
        colorStops: [{
          offset: 0,
          color: '#8fd6fd' // 浅色
        }, {
          offset: 1,
          color: '#2f63e7' // 深色
        }]
      },
      width: 3
    }
  }, {
    data: [],
    type: 'line',
    symbol: 'circle',

    itemStyle: {
      normal: {
        color: '#48a798', //改变折线点的颜色
        lineStyle: {
          width: 3,
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [{
              offset: 0,
              color: '#ccf9fe' // 浅色
            }, {
              offset: 1,
              color: '#24d4e7' // 深色
            }]
          }
        }
      }
    },
    /*  areaStyle: {
       color: {
         type: 'linear',
         x: 0,
         y: 0,
         x2: 0,
         y2: 1,
         colorStops: [{
           offset: 0, color: 'rgba(72,167,152,0.2)' // 0% 处的颜色
         }, {
           offset: 1, color: 'rgba(72,167,152,1)' // 100% 处的颜色
         }],
         global: false // 缺省为 false
       }
     } */
  }]

}